﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Text;
using System.Xml.Serialization;

namespace Model
{
    [Serializable]
    
    public class OrderDetail:ISerializable
    {
        [Key]
        public int OrderDetailId { get; set; }

        [ForeignKey("Product")]
        public string ProductId { get; set; }

        [ForeignKey("Order")]
        public int OrderId { get; set; }

        public int Quantity { get; set; }
        public virtual Product Product { get; set; }
        public virtual Order Order { get; set; }


        public OrderDetail()
        {

        }
        public OrderDetail(SerializationInfo info, StreamingContext context)
        {
            OrderDetailId = info.GetInt32("OrderDetailId");
            ProductId = info.GetString("ProductId");
            OrderId = info.GetInt32("OrderId");
            Quantity = info.GetInt32("Quantity");
        }

        [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("OrderDetailId", OrderDetailId);
            info.AddValue("ProductId", ProductId);
            info.AddValue("OrderId", OrderId);
            info.AddValue("Quantity", Quantity);
        }
    }
}
